package com.example.myapplication.module1.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.example.myapplication.R
import com.example.myapplication.databinding.ItemCustomerBinding
import com.example.myapplication.entity.CustomerInfoBean
import com.example.mylibrary.adapter.BaseRecyclerAdapter

class CustomerAdapter(context: Context) : BaseRecyclerAdapter<ItemCustomerBinding>(context) {

    var customerInfoList = mutableListOf<CustomerInfoBean>()
        set(value) {
            field = value
            notifyDataSetChanged()
        }

    override fun bindHolder(holder: BaseViewHolder, position: Int) {
        val customerInfoBean = customerInfoList[position]
        viewBinding.tvCode.text = customerInfoBean.code
        viewBinding.tvName.text = customerInfoBean.cname
        viewBinding.tvCustomerType.text = customerInfoBean.typesname
    }

    override fun getItemCount(): Int {
        return customerInfoList.size
    }

    override fun getBinding(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ItemCustomerBinding {
        return ItemCustomerBinding.inflate(inflater,parent,false)
    }

}
